package cn.xuqiudong.rpc.demo.consumer.service;

import cn.xuqiudong.rpc.demo.common.api.QiudongInterface;
import org.springframework.stereotype.Service;
import cn.xuqiudong.rpc.demo.common.api.DemoInterface;
import cn.xuqiudong.rpc.demo.common.model.OneModel;
import cn.xuqiudong.rpc.spring.annotation.XqdReference;

import java.util.List;

/**
 * 描述: 消费者service
 * @author Vic.xu
 * @date 2022-03-01 17:37
 */
@Service("consumerService")
public class ConsumerService {

    /**
     * 注入接口：应被转为为对应的代理类 最终调用远程服务
     */
    @XqdReference
    private DemoInterface demoInterface;

    @XqdReference
    private QiudongInterface qiudongInterface;

    /**
     * 返回列表
     * @param num
     * @return
     */
    public List<OneModel> list(int num){
        return demoInterface.list(num);
    }


    /**
     * 根据id查找
     * @param id
     * @return
     */
    public OneModel detail(int id){
        return demoInterface.detail(id);
    }

    public OneModel search(String name){
        return demoInterface.search(name);
    }

    public String from(String name) {
        return qiudongInterface.from(name);
    }
}
